﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>添加配件</title>
 
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" type="text/css" href="~/H-ui/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="~/H-ui/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="~/H-ui/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="~/H-ui/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="~/H-ui/static/h-ui.admin/css/style.css" />
    <link href="~/css/img.css" rel="stylesheet" />

</head>
<body class="bb1">

    <div align=center class="d1">
        <marquee style="FONT-SIZE: 35pt; WIDTH: 400px; FILTER: shadow(color=#AF0530); LINE-HEIGHT:15pt; FONT-FAMILY: 隶书; HEIGHT: 80px" scrollamount=6>
            <h2 style="margin-top:0px;text-align:center"><font color=#f90b46>添加配件 </font></h2>
        </marquee>
    </div>
    <div>
        
        <hr style="display:block" />
        <aside class="Hui-aside" style="position: absolute; top: 65px; margin-top: 0; background-image: url('../../img/bjt7-1.gif');background-repeat:no-repeat;background-size:100% 100%; " >
            <div  id="div1" class="menu_dropdown bk_2" style="position:relative;top:30px;">

            </div>
            </aside>
            <div>
                <div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onclick="displaynavbar(this)"></a></div>
                <form action="/Parts/AddFile" method="post" enctype="multipart/form-data" target="frameFile">
                    <table class="table table-border table-bordered table-hover table-sort" style="margin-left:150px">
                        <tr class="text-c">
                            <td>你选择的节点</td>
                            <td><span id="span2"></span></td>
                        </tr>
                        <tr class="text-c">
                            <td>配件名称：</td>
                            <td>
                                <input type="text" name="names" style="width:30%" />
                            </td>
                        </tr>
                        <tr class="text-c">
                            <td>配件图片：</td>
                            <td>
                                <input type="file" name="images" id="Files" onchange="fileshow()" /><input type="submit" value="上传图片" class="btn-success radius"/>
                            </td>
                        </tr>
                        <tr class="text-c">
                            <td></td>
                            <td><img id="imgs" src="" width="200" height="100" /></td>
                        </tr>
                        <tr class="text-c">
                            <td></td>
                            <td><input type="button" onclick="ziji()" class="btn btn-success" value="添加子级" />  <input type="button" class="btn btn-success" onclick="tongji()" value="添加同级" /></td>
                        </tr>
                    </table>
                </form>
                <iframe id='frameFile' name='frameFile' style='display: none;'></iframe>
</div>
</div>
    <footer class="footer mt-20">
        <div class="container">
            <p>
                关于我们  |  联系我们    |  项目合作  |  广告植入   |  友情链接<br />
                版权所有 京ICP备11009069<br />
                Copyright ©2016 Gaotie.cn
            </p>
        </div>
    </footer>
    <script type="text/javascript" src="~/H-ui/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="~/H-ui/lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="~/H-ui/static/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="~/H-ui/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->
    <!--请在下方写此页面业务相关的脚本-->
    <script src="~/H-ui/lib/jquery.contextmenu/jquery.contextmenu.r2.js"></script>
    <script src="~/Scripts/jquery-ui-1.8.24.js"></script>
    <script type="text/javascript">

        function fileshow()
        {
            var img = document.getElementById("Files").files[0];
            var file = new FileReader();
            file.readAsDataURL(img);
            file.onload =function () {
              document.getElementById("imgs").src =file.result;
            }
           
        }


    show();
    function show() {
        $.ajax({
            type: "post",
            url: "/Parts/Partent",
            success: function (obj) {
                var htmltab = "";
                $("#div1").empty();
                for (var m = 0; m < obj.length; m++) {
                    var pid = obj[m].WagonId;

                    htmltab += "<dl id=\"menu-" + m + "\">"
                    htmltab += "<dt onclick=\"ff(" + pid + ")\"><i class=\"Hui-iconfont\" style='color:#ff0000'>&#xe616;</i><span>" + obj[m].WagonName + "</span><i class=\"Hui-iconfont menu_dropdown-arrow\"  >&#xe6d5;</i></dt>"
                    htmltab += "<dd id=\"dd" + pid + "\"><span id=\"mm" + pid + "\">" + parentId(pid) + "</span></dd>"

                    htmltab += "</dl>"
                    $("#div1").html(htmltab);
                }


            }
        })
    }
    //显示子级节点
    function parentId(id) {

        $.ajax({
            type: "post",
            url: "/Parts/PartentId",
            data: { id: id },
            success: function (result) {
               var htmltab1 = "";
               $("#mm" + id).empty();
                for (var j = 0; j < result.length; j++) {
                    var pid = result[j].RailWayId;
                    htmltab1 += "<dl id=\"menu-" + j + "\">"                  
                    htmltab1 += "<dt >&nbsp;&nbsp;&nbsp;<i class=\"Hui-iconfont\"></i><span onclick=\"zi(" + pid + ")\">" + result[j].RailWayName + "</span><i class=\"Hui-iconfont menu_dropdown-arrow\" onclick=\"ff1(" + pid + ")\" >&#xe6d5;</i></dt>"
                    htmltab1 += "<dd id=\"dd1" + pid + "\"><span id=\"mm1" + pid + "\">" + parentlastId(pid) + "</span></dd>"
                    htmltab1 += "</dl>"
                  
                    
                }
               
                $("#mm" + id).html(htmltab1);
            }
        })
    }

    //显示最后一级节点
    function parentlastId(id) {

        $.ajax({
            type: "post",
            url: "/Parts/PartentLastId",
            data: { id: id },
            success: function (result) {
               
                var htmltab1 = "";
                $("#mm1" + id).empty();
                for (var j = 0; j < result.length; j++) {


                    htmltab1 += "<ul><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp" + result[j].PartsName + "</li></ul>"
                }
                $("#mm1" + id + "").html(htmltab1);
            }
        })
    }

    function ff(id) {
        if ($("#dd" + id).attr("class") == "selected") {
            $("#dd" + id).removeClass("selected")
            $(this).addClass("selected");
        }
        else {
            $("#dd" + id).addClass("selected")
            $(this).removeClass("selected");
        }

    }

    function ff1(id) {
        if ($("#dd1" + id).attr("class") == "selected") {
            $("#dd1" + id).removeClass("selected")
            $(this).addClass("selected");
        }
        else {
            $("#dd1" + id).addClass("selected")
            $(this).removeClass("selected");
        }

    }

    //获取车厢节点
    function zi(id) {
        $.ajax({
            type: "post",
            url: "/Parts/BackName",
            data: { id: id },
            success: function (data) {
                $("#span2").text(data);
            }
        })
    }
      ///添加子级
    function ziji()
    {
        $.ajax({
            type: "post",
            url: "/Parts/AddParts",
            data:{id:1},
            success:function(obj)
            {
                if(obj)
                {
                    alert('添加成功');
                    return;
                }
                alert('添加失败')
            }
        })
    }
///添加同级
    function tongji() {
        $.ajax({
            type: "post",
            url: "/Parts/AddParts",
            data:{id:2},
            success: function (obj) {
                if (obj) {
                    alert('添加成功');
                    return;
                }
                alert('添加失败')
            }
        })
    }
    </script>

</body>

</html>
